<?php

use think\Db;
use think\migration\Migrator;
use think\migration\db\Column;

class CreateAdminAccount extends Migrator
{
    
    public function up()
    {
        $arr = [
            'type'=>1,
            'item'=>['Admin','Advert','Alliance','Business','ColumnInfo'],
        ];
        Db::name('admin')->insert([
            'id' => 1,
            'username' => 'admin',
            'nickname' => 'admin',
            'password' => md5('admin123'),
            'authority' => json_encode($arr),
            'create_time' => time(),
        ]);
        Db::name('admin')->insert([
            'username' => 'test',
            'nickname' => '测试',
            'password' => md5('admin123'),
            'authority' => json_encode($arr),
            'create_time' => time(),
        ]);
        Db::name('admin')->insert([
            'username' => 'test1',
            'nickname' => '测试',
            'password' => md5('admin123'),
            'authority' => json_encode($arr),
            'create_time' => time(),
        ]);
    }

    public function down()
    {
        Db::name('admin')->where('id', '>', 0)->delete();
    }
}
